package com.yonyougov.devops.cruxcisupport.commitcontext;

import com.yonyougov.devops.cruxcisupport.commitcontext.vo.CommitContextInfoVo;
import com.yonyougov.devops.cruxcisupport.commitcontext.vo.CommitContextVo;
import com.yonyougov.devops.fwc.core.dao.impl.BaseDaoImpl;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * t_commit_context数据层实现
 */
@Repository
public class CommitContextDaoImpl extends BaseDaoImpl<CommitContextEntity, BigInteger> implements CommitContextDao {
    //<!--用户自定义代码开始-->
    private final SqlSessionTemplate sqlSessionTemplate;

    public CommitContextDaoImpl(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    /**
     * 根据提测Id 查询提测内容详情
     * 条件: 提测单id
     *
     * @param commitTestId [java.math.BigInteger]
     * @return List<CommitContextDevelopUserVo>
     */
    @Override
    public List<CommitContextVo> findListByCommitTestId(BigInteger commitTestId) {
        String statement = CommitContextEntity.class.getName() + "Mapper.findCCDUVoByCommitTestId";
        return sqlSessionTemplate.selectList(statement, commitTestId);
    }

    /**
     * 查询提测内容详情
     * 条件: 提测单id
     *
     * @param commitTestId
     * @return [java.util.List: com.yonyougov.devops.cruxcisupport.commitcontext.vo.CommitContextInfoVo]
     */
    @Override
    public List<CommitContextInfoVo> findCommitContextByCommitTestId(BigInteger commitTestId) {
        String statement = CommitContextEntity.class.getName() + "Mapper.findCommitContextByCommitTestId";
        return sqlSessionTemplate.selectList(statement, commitTestId);
    }

    /**
     * 更新提测内容
     * 类型: 批量
     *
     * @param contextEntities 提测内容实体类
     */
    @Override
    public void batchUpdateCommitTestId(List<CommitContextEntity> contextEntities) {
        String statement = CommitContextEntity.class.getName() + "Mapper.batchUpdateCommitTestId";
        sqlSessionTemplate.selectList(statement, contextEntities);
    }

    //<!--用户自定义代码结束-->
}